﻿using System;

namespace KWatkins.FluentMoqBuilder.Argument
{
	internal sealed class EnumValidation<T> : ArgumentValidation<T>, IEnum<T>
		where T : struct
	{
		internal EnumValidation(T argument, string parameterName)
			: base(argument, parameterName)
		{
		}

		IEnum<T> IEnum<T>.IsDefined()
		{
			if (!Enum.IsDefined(typeof(T), Argument))
			{
				throw new ArgumentOutOfRangeException(ParameterName, Argument, "Value is not defined.");
			}

			return this;
		}
	}
}
